﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient; 

public partial class doimatkhauadmin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void txtTenDN_TextChanged(object sender, EventArgs e)
    {

    }
    protected void btDongy_Click(object sender, EventArgs e)
    {
        try
        {

            String User = txtTenDN.Text;
            String Matkhau = txtMatkhau.Text;
            String Matkhaumoi = txtMatkhaumoi.Text;
            String StrCnn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
            SqlConnection cnn = new SqlConnection(StrCnn);
            String LenhSQL = "select * from AdMin where username='" + User + "' and  pass='" + Matkhau + "'";
            DataTable dt = XLDL.Docbang(LenhSQL);
            if (dt.Rows.Count == 0)
                lbBaoloi.Text = "Sai tên đang nhập hoặc mật khẩu";
            else
            {

                string str = "UPDATE AdMin Set pass='" + Matkhaumoi + "'  WHERE username ='" + User + "'";
                XLDL.thuchienlenh(str);
                PanelThongbao.Visible = true;
            }
        }
        catch
        {
            lbBaoloi.Text = "Thao tác cập nhật dữ liệu thất bại!";
        } 
    }
}